function t(t, a) {
    if (!(t instanceof a)) throw new TypeError("Cannot call a class as a function");
}

var a = function() {
    function t(t, a) {
        for (var i = 0; i < a.length; i++) {
            var e = a[i];
            e.enumerable = e.enumerable || !1, e.configurable = !0, "value" in e && (e.writable = !0), 
            Object.defineProperty(t, e.key, e);
        }
    }
    return function(a, i, e) {
        return i && t(a.prototype, i), e && t(a, e), a;
    };
}(), i = function() {
    function i() {
        t(this, i), this.circleTime = 5e3, this.createAnimations(), this.initValues(), this.setPageData();
    }
    return a(i, [ {
        key: "getPage",
        value: function() {
            var t = getCurrentPages();
            return t[t.length - 1];
        }
    }, {
        key: "createAnimations",
        value: function() {
            this.animation = wx.createAnimation({
                transformOrigin: "100px 100px",
                duration: this.circleTime,
                timingFunction: "linear",
                delay: 0
            });
        }
    }, {
        key: "initValues",
        value: function() {
            this.timer = null, this.opacityTimer = null, this.repeat = 2;
        }
    }, {
        key: "setPageData",
        value: function() {
            this.getPage().setData({
                "scanbar.progressPercent": "0",
                "scanbar.loadingDecIcoShow": !1,
                "scanbar.circle": "/biliang/res/gradient_circle.png",
                "scanbar.circle_dot": "/biliang/res/gradient_dot.png"
            });
        }
    }, {
        key: "init",
        value: function(t) {
            if (t && t.length) {
                t.length > 20 && (t = t.slice(0, 20));
                var a = [];
                this.animations = [];
                for (var i = 0; i < t.length; i++) {
                    for (var e = this.randomPoint(), n = e[0], r = e[1], s = !1, o = 0; o < a.length; o++) {
                        var h = a[o];
                        if (this.isRectRepeat(n, r, h.x, h.y)) {
                            n = (e = this.randomPoint())[0], r = e[1], s = !0;
                            break;
                        }
                    }
                    for (;s; ) {
                        n = (e = this.randomPoint())[0], r = e[1], s = !1;
                        for (var c = 0; c < a.length; c++) {
                            var u = a[c];
                            if (this.isRectRepeat(n, r, u.x, u.y)) {
                                s = !0;
                                break;
                            }
                        }
                    }
                    var m = 360 - e[2] + 90;
                    m >= 360 && (m -= 360);
                    var l = {
                        img: t[i],
                        left: n + 100 + "px",
                        top: 100 - r + "px",
                        time: this.circleTime * (m / 360),
                        x: n,
                        y: r,
                        A: e[2]
                    };
                    a.push(l), this.animations.push(wx.createAnimation({
                        duration: 500,
                        timingFunction: "linear",
                        delay: 0
                    }));
                }
                return this.getPage().setData({
                    "scanbar.images": a
                }), this.instance;
            }
        }
    }, {
        key: "isOutOfCircle",
        value: function(t, a) {
            return Math.sqrt((t + 32) * (t + 32) + a * a) >= 140 || Math.sqrt(t * t + (32 - a) * (32 - a)) >= 140 || Math.sqrt((t + 32) * (t + 32) + (32 - a) * (32 - a)) >= 140;
        }
    }, {
        key: "randomPoint",
        value: function() {
            for (var t = 360 * Math.random(1), a = 100 * Math.random(1), i = a * Math.cos(Math.PI / 180 * t), e = a * Math.sin(Math.PI / 180 * t); this.isOutOfCircle(i, e); ) {
                for (t = 360 * Math.random(1), a = 100 * Math.random(1); a > 118; ) a = 100 * Math.random(1);
                i = a * Math.cos(Math.PI / 180 * t), e = a * Math.sin(Math.PI / 180 * t);
            }
            for (;i >= -100 && i <= 70 && e >= -40 && e <= 70; ) {
                for (t = 360 * Math.random(1), a = 100 * Math.random(1); a > 118; ) a = 100 * Math.random(1);
                for (i = a * Math.cos(Math.PI / 180 * t), e = a * Math.sin(Math.PI / 180 * t); this.isOutOfCircle(i, e); ) {
                    for (t = 360 * Math.random(1), a = 100 * Math.random(1); a > 118; ) a = 100 * Math.random(1);
                    i = a * Math.cos(Math.PI / 180 * t), e = a * Math.sin(Math.PI / 180 * t);
                }
            }
            var n = [];
            return n.push(i), n.push(e), n.push(t), n;
        }
    }, {
        key: "isRectRepeat",
        value: function(t, a, i, e) {
            return Math.min(t + 35, i + 35) >= Math.max(t, i) && Math.min(a + 35, e + 35) >= Math.max(a, e);
        }
    }, {
        key: "showImgs",
        value: function() {
            this.animation.rotateZ(360).step(), this.getPage().setData({
                "scanbar.circleAnimation": this.animation.export()
            }), this.currentTime = 500;
            this.opacityTimer = setInterval(function() {
                for (var t = this.getPage().data.scanbar.images, a = [], i = 0; i < t.length; i++) {
                    var e = t[i], n = e.time;
                    e.animObj;
                    n > 500 ? this.currentTime > n - 200 && n + 300 >= this.currentTime ? a.push(this.animations[i].opacity(1).step().export()) : a.push(this.animations[i].opacity(0).step().export()) : this.currentTime > n && n + 500 >= this.currentTime ? a.push(this.animations[i].opacity(1).step().export()) : a.push(this.animations[i].opacity(0).step().export());
                }
                this.currentTime >= this.circleTime && (this.currentTime = 500), this.currentTime += 500, 
                this.currentTime >= this.circleTime ? (console.log("this.currentTime", this.currentTime), 
                this.animation.rotateZ(360 * this.repeat).step(), this.getPage().setData({
                    "scanbar.circleAnimation": this.animation.export(),
                    "scanbar.animations": a
                }), this.repeat++) : this.getPage().setData({
                    "scanbar.animations": a
                });
            }.bind(this), 500);
        }
    }, {
        key: "startScan",
        value: function() {
            this.timer && null !== this.timer || (this.stopScan(!1), this.timer = setTimeout(function() {
                this.showImgs();
            }.bind(this), 500));
        }
    }, {
        key: "setProgress",
        value: function(t) {
            return this.getPage().setData({
                "scanbar.progressPercent": t
            }), this.instance;
        }
    }, {
        key: "stopScan",
        value: function(t) {
            this.animation.rotateZ(0).step({
                duration: 0
            });
            for (var a = this.getPage().data.scanbar.images, i = [], e = 0; e < a.length; e++) i.push(this.animations[e].opacity(0).step().export());
            this.getPage().setData({
                "scanbar.loadingDecIcoShow": t,
                "scanbar.circleAnimation": this.animation.export(),
                "scanbar.animations": i
            }), t && !0 === t && (clearTimeout(this.timer), clearInterval(this.opacityTimer), 
            this.initValues());
        }
    } ]), i;
}();

module.exports = i;